﻿using PelitaProduksi.Controller;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PelitaProduksi.Model
{
    public class BaseProduksi
    {
        public virtual string getID(string table)
        {
            MySQLController c = new MySQLController();
            c.Open();
            object result = c.ExecuteScalar(string.Format
                ("select MAX(No) from {0}", table));
            c.Close();
            string temp = result.ToString();
            int count = Int32.Parse(temp.Substring(6, 4));
            // Add 1 to the ID for the next one
            StringBuilder output = new StringBuilder();
            output.Append(temp.Substring(0, 6));
            output.Append(count + 1);
            return output.ToString();
        }

        public virtual void insert() { }

        public virtual void edit(string id) { }
    }
}
